# -*- coding: utf-8 -*-
# @Time : 2023/1/10 10:01
# @Author : Z
# @Email : 1473858993@qq.com
# @File : api_base.py
# @Project : apitwo
import json

import requests


class ApiBase:
    # 类变量，通过类名访问
    session = requests.session()

    def send_request(self, method, url, data, **kwargs):
        method = str(method).lower()
        rep = None
        if method == 'get':
            rep = ApiBase.session.request(method, url=url, params=data, allow_redirects=False, **kwargs)
        else:
            # data_json = json.dumps(**kwargs['json'])
            rep = ApiBase.session.request(method, url=url, data=data, allow_redirects=False, **kwargs)
        return rep


apibase = ApiBase()
